<template>
	<view>
		<view class="content">
			<view class="list">
				<view class="row" v-for="(row,index) in addressList" :key="index" @tap="select(row)">
					<view class="left">
						<view class="head">
							{{row.bank_name|substr(0,2)}}
						</view>
					</view>
					<view class="center">
						<view class="name-tel">
							<view class="name">{{row.bank_name}}</view>
						</view>
						<view class="address">
							{{row.card_id}}
						</view>
					</view>
					<!-- <view class="right">
						<view style="color: red;font-weight: 800;" @tap.stop="unbind(row)">
							解绑
						</view>
					</view> -->
				</view>
			</view>
		</view>
		<view class="add">
			<view class="btn" @tap="add">
				<view class="icon tianjia"></view>新增银行卡
			</view>
		</view>
	</view>
</template>
<script>
	import {
		FastList,
		UnbindCard
	} from "@/api/fast.js"
	export default {
		data() {
			return {
				addressList: []
			};
		},
		filters: {
			substr(value, start, length) {
				console.log(value);
				return value.substring(start, length)
			},
		},
		onLoad(e) {

		},
		onShow() {
			this.BankList()
		},
		methods: {
			BankList() {
				FastList().then(res => {
					console.log(res);
					this.addressList = res.data
				})
			},
			unbind(row) {
				uni.showModal({
					title: '提示',
					content: '确定要解绑此银行卡吗',
					success: (res) => {
						if (res.confirm) {
							UnbindCard({
								token_no: row.token_no
							}).then(data => {
								uni.showToast({
									title: data.message,
									icon: 'none'
								})
								if (data.status == 1) {
									this.addressList = [];
									setTimeout(() => {
										this.BankList()
									}, 200)
								} else {

								}
							})
						}
					}
				})
			},
			add() {
				uni.navigateTo({
					url: '/pages/user/bindcard/bindbank/index'
				})
			}
		}
	}
</script>

<style lang="scss">
	view {
		display: flex;
	}

	.icon {
		// &.bianji {
		// 	&:before{content:"\e61b";}
		// }
		// &.tianjia {
		// 	&:before{content:"\e81a";}
		// }
	}

	.add {
		position: fixed;
		bottom: 0;
		width: 100%;
		height: 120upx;
		justify-content: center;
		align-items: center;

		.btn {
			box-shadow: 0upx 5upx 10upx rgba(0, 0, 0, 0.4);
			width: 70%;
			height: 80upx;
			border-radius: 80upx;
			background-color: #f06c7a;
			color: #fff;
			justify-content: center;
			align-items: center;

			.icon {
				height: 80upx;
				color: #fff;
				font-size: 30upx;
				justify-content: center;
				align-items: center;
			}

			font-size: 30upx;
		}
	}

	.list {
		flex-wrap: wrap;

		.row {
			width: 96vw;
			padding: 20upx 2%;

			.left {
				width: 90upx;
				flex-shrink: 0;
				align-items: center;

				.head {
					width: 70upx;
					height: 70upx;
					background: linear-gradient(to right, #ccc, #aaa);
					color: #fff;
					justify-content: center;
					align-items: center;
					border-radius: 60upx;
					font-size: 25upx;
				}
			}

			.center {
				width: 100%;
				flex-wrap: wrap;

				.name-tel {
					width: 100%;
					align-items: baseline;

					.name {
						font-size: 34upx;
					}

					.tel {
						margin-left: 30upx;
						font-size: 24upx;
						color: #777;
					}

					.default {

						font-size: 22upx;

						background-color: #f06c7a;
						color: #fff;
						padding: 0 18upx;
						border-radius: 24upx;
						margin-left: 20upx;
					}
				}

				.address {
					width: 100%;
					font-size: 24upx;
					align-items: baseline;
					color: #777;
				}
			}

			.right {
				flex-shrink: 0;
				align-items: center;
				margin-left: 20upx;

				.icon {
					justify-content: center;
					align-items: center;
					width: 80upx;
					height: 60upx;
					border-left: solid 1upx #aaa;
					font-size: 40upx;
					color: #777;
				}
			}
		}
	}
</style>
